package com.taocyb.framework.security.captcha.kaptcha;

import java.awt.Color;
import java.awt.Font;
import java.util.Random;

/**
 * 验证码参数
 */
public final class KaptchaUtils {
	
	public static final int LOGIN_IMG_PART = 5; //背景图片分为几部分
	
    public static Font FIRST_FONT = new Font("Arial", Font.BOLD,16);
	
	public static Font[] FONTS = new Font[]{
		new Font("Arial", Font.BOLD,15),
		new Font("Arial", Font.BOLD,17),
		new Font("Arial", Font.BOLD,18)
	};
	
    /**
     * 产生随机颜色
     * @param lower
     * @param upper
     * @return
     * @create_time 2011-10-28 下午03:20:10
     */
    public static Color getRandColor(int lower, int upper) {
        Random random = new Random();
        if (upper > 255)
            upper = 255;
        if (upper < 1)
            upper = 1;
        if (lower < 1)
            lower = 1;
        if (lower > 255)
            lower = 255;
        int r = lower + random.nextInt(upper - lower);
        int g = lower + random.nextInt(upper - lower);
        int b = lower + random.nextInt(upper - lower);
        return new Color(r, g, b);
    }
}
